package com.wangtao.share;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
    private GridView gridView;
    private List<Map<String, Object>> datas;
    private SimpleAdapter simpleAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        gridView = (GridView) findViewById(R.id.gridView);
        initDatas();
        simpleAdapter = new SimpleAdapter(this, datas, R.layout.item_main, new String[]{"pic", "text"},
                new int[]{R.id.imageView, R.id.textView});

        gridView.setAdapter(simpleAdapter);

        gridView.setOnItemClickListener(this);
    }

    sdujlks;ldkflks;lk;flsm.mf;lsdmflkdms;lsml;kfnjksdkj;mflksdjn;jksdfnjk;fnsdkjnsdfkjnmfsdn;klsdnb jlsdj
    /**
     * 初始化数据源
     */
    private void initDatas() {
        datas = new ArrayList<>();

        datas.add(getMapObject("address_book", R.mipmap.p0));
        datas.add(getMapObject("calendar", R.mipmap.p1));
        datas.add(getMapObject("camera", R.mipmap.p2));
        datas.add(getMapObject("clock", R.mipmap.p3));
        datas.add(getMapObject("games_control", R.mipmap.p4));
        datas.add(getMapObject("messenger", R.mipmap.p5));
        datas.add(getMapObject("ringtone", R.mipmap.p6));
        datas.add(getMapObject("settings", R.mipmap.p7));
        datas.add(getMapObject("speech_balloon", R.mipmap.p8));
        datas.add(getMapObject("address_book", R.mipmap.p9));
        datas.add(getMapObject("calendar", R.mipmap.p10));
        datas.add(getMapObject("camera", R.mipmap.p11));
        datas.add(getMapObject("clock", R.mipmap.p12));
        datas.add(getMapObject("games_control", R.mipmap.p13));
        datas.add(getMapObject("messenger", R.mipmap.p14));

    }

    private Map<String, Object> getMapObject(String text, Object pci) {
        Map<String, Object> map = new HashMap<>();
        map.put("pic", pci);
        map.put("text", text);
        return map;

        都是比较好放松空间就开始发动机可浪费大家来看就是放到了空间发了的减肥了开始的记录卡房间多少了空间是打发了空间发呆了空间发了
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(this, "我是:" + datas.get(position).get("text"), Toast.LENGTH_SHORT).show();
    }
}
